package image;

import image.dithering.Dithering;

public class Image extends BaseImagen {

	private static final long serialVersionUID = -5555559297312323447L;

	public Image(String url) {
		super(url);
	}
	
	@Override
	protected int[][] getDither8() {

		System.out.println("dithering");
		return Dithering.getDithered8Of(this.getRGBtoCMY());
		
	}

	@Override
	protected int[][][] getRGBtoCMY() {
		System.out.println("converting RGB to CMY");
		int[][][] ret = new int[3][imagenOriginal.height][imagenOriginal.width];
		imagenOriginal.loadPixels();
		int[] rgb = new int[3];

			for (int i=0;i<imagenOriginal.height;i++)
				for (int j=0;j<imagenOriginal.width;j++) {
					int c = imagenOriginal.pixels[imagenOriginal.width*i+j];
					rgb = this.getRGBfromHex(c);
					
					ret[0][i][j] = 255-rgb[0];
					ret[1][i][j] = 255-rgb[1];
					ret[2][i][j] = 255-rgb[2];
				}
		return ret;
	}

}
